<template>
  <div class="app-container">
    <div class="change">
      <el-divider content-position="left">基本信息</el-divider>
      <p>
        <span>品牌：</span>
        <span>{{tempData.brand}}</span>
      </p>
      <p>
        <span>设备名：</span>
        <span>{{tempData.commodityName}}</span>
      </p>
      <p>
        <span>单位：</span>
        <span>{{tempData.nuit}}</span>
      </p>
      <p>
        <span>数量：</span>
        <span>{{tempData.number}}</span>
      </p>
      <p>
        <span>位号：</span>
        <span>{{tempData.bitNumber}}</span>
      </p>
      <p>
        <span>责任人：</span>
        <span>{{tempData.maintainPerson}}</span>
      </p>
      <p>
        <span>是否定期检修：</span>
        <span>{{tempData.isRepair}}</span>
      </p>
      <p>
        <span>定期检修周期：</span>
        <span>{{tempData.repairPeriod}}</span>
      </p>
      <p>
        <span>备注：</span>
        <span>{{tempData.remarks}}</span>
      </p>
      <p>
        <span>规格型号：</span>
        <span>{{tempData.model}}</span>
      </p>
      <p>
        <span>部门：</span>
        <span>{{tempData.departments}}</span>
      </p>
      <!-- <p>
        <span>序号：</span>
        <span>{{tempData.serialnumber}}</span>
      </p> -->
      <p>
        <span>固定资产编号：</span>
        <span>{{tempData.assetnumber}}</span>
      </p>
      <p>
        <span>参数：</span>
        <span>{{tempData.parameters}}</span>
      </p>
      <p>
        <span>安装时间：</span>
        <span>{{tempData.installtime}}</span>
      </p>
      <p>
        <span>使用时间：</span>
        <span>{{tempData.usetime}}</span>
      </p>
      <p>
        <span>承包人：</span>
        <span>{{tempData.rateOfWork}}</span>
      </p>
      <p>
        <span>图片：</span>
        <img :src="tempData.imgurl" class="proimg" alt="">
      </p>
      <p>
        <span>二维码：</span>
        <img :src="tempData.erweima" class="proimg" alt="">
      </p>
    </div>
    <div class="fileup" v-if="fileNum.length != 0">
      <el-divider content-position="left">文档信息</el-divider>
      <div class="uping" v-for="(item,index) in fileNum" :key="index">
        <p>
          <span>资料名</span>
          <span>{{item.filename}}</span>
        </p>
        <p>
          <span>上传资料</span>
          <strong v-if="item.filePath">{{item.filename}}</strong>
          <strong v-if="item.filePath" @click="downLoad(item.filePath)">
            下载
            <i class="el-icon-download" />
          </strong>
        </p>
      </div>
    </div>
    <div class="zishebei">
      <el-divider content-position="left">子设备信息</el-divider>
      <div class="zd3-btm">
        <el-table
          :data="tableData"
          style="width: 100%;border-radius: 8px;"
          :show-header="true"
          border
        >
          <el-table-column type="index" align="center" label="序号" width="80" />
          <el-table-column align="center" width="100" prop="bitNumber" label="设备序列号" />
          <el-table-column align="center" prop="brand" label="设备名称" />
          <el-table-column align="center" prop="model" label="设备型号" />
          <el-table-column align="center" width="200" prop="powers" label="性能参数">
            <template slot-scope="scope">
              <div class="ellisp">{{scope.row.powers}}</div>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="maintainPerson" label="检修人" />
          <el-table-column align="center" prop="texture" label="保养类型" />
          <el-table-column align="center" prop="lubrication" label="润滑方式" />
          <el-table-column align="center" prop="number" label="数量" />
          <el-table-column align="center" width="100" label="操作">
            <template slot-scope="scope">
              <!-- <el-button type="text" size="small" @click="look(scope.row)">查看</el-button> -->
              <el-button type="text" size="small" v-if="scope.row.fileId" @click="downloadFile(scope.row,scope.$index)">下载文档</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
    <div class="submits">
      <!-- <div class="nosave" @click="nosaveOrder">取消</div> -->
      <div class="save" @click="back">返回</div>
    </div>
  </div>
</template>

<script>
import { getUserFiles } from "@/api/people";
export default {
  data() {
    return {
      tempData: {},
      islook: false,
      tableData: [],
      fileNum: [],
      twoClassify: [],
      writeOradd: 0 //新增0，编辑1
    };
  },
  mounted() {
    // this.cangkuList();
    console.log(this.$route.params);
    this.tempData = JSON.parse(this.$route.params.options);
    this.tableData = this.tempData.departmentSubfacilities;
    console.log(this.tempData);
    this.getFilesList(this.tempData.id);
  },
  methods: {
    downloadFile(item) {
      window.location.href = item.fileId;
    },
    // 获取商品文档信息
    getFilesList(id) {
      getUserFiles({ parentId: id }).then(res => {
        console.log(res);
        if (res.data.list.length != 0) {
          this.fileNum = [];
          res.data.list.map(item => {
            this.fileNum.push({
              filename: item.fileDescribe,
              filePath: item.fileName
            });
          });
        }
      });
    },
    // 选择商品分类
    handleChange(value) {
      console.log(value);
      this.tempData.goodsId = value[1];
    },
    downLoad(filepath) {
      window.location.href = filepath;
    },
    nosaveOrder() {
      this.$router.go(-1);
    },
    back() {
      this.$router.go(-1);
    }
  }
};
</script>

<style scoped lang="scss">
.ellisp{
	width: 100%;
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
	overflow: hidden;
	text-align: left;
}
.proimg{
  width: 100px;
  height: 100px;
}
.zishebei {
  background: #fff;
  padding: 20px;
  border-radius: 0 0 8px 8px;
}
.change {
  display: flex;
  flex-wrap: wrap;
  background: #fff;
  border-radius: 8px 8px 0 0;
  padding: 20px;
  > p {
    width: 33%;
    font-size: 14px;
    display: flex;
    align-items: center;
    color: #333;
    /deep/.el-input__inner {
      // width: inherit;
      background: none;
      height: 32px;
      // line-height: 32px;
      color: #333;
      border: 1px solid rgba(0, 0, 0, 0.1);
      padding: 0 25px;
    }
    /deep/.el-input__icon {
      line-height: 32px;
    }
    .userselect {
      // max-width: 250px;
      flex: 1;
    }

    > span {
      display: block;
      width: 120px;
      text-align: right;
      padding-right: 15px;
      &:last-child {
        text-align: left;
        color: #888;
        flex: 1;
      }
    }
    > input {
      width: inherit;
      flex: 1;
      height: 32px;
      border-radius: 3px;
      border: 1px solid rgba(0, 0, 0, 0.1);
      padding-left: 10px;
      color: #333;
    }
  }
}
.submits {
  display: flex;
  padding: 15px 20px;
  background: #fff;
  margin-top: 20px;
  border-radius: 8px;
  justify-content: flex-end;
  align-items: center;
  > div {
    width: 80px;
    height: 32px;
    text-align: center;
    line-height: 32px;
    color: #fff;
    font-size: 14px;
    border-radius: 4px;
    margin-left: 30px;
    cursor: pointer;
  }
  .add {
    background: #18a05e;
  }
  .save {
    background: #2196f3;
  }
  .nosave {
    background: #999;
  }
}
.fileup {
  position: relative;
  padding: 20px;
  background: #fff;
  display: flex;
  flex-wrap: wrap;
  // align-items: center;
  justify-content: space-between;
  .uping {
    width: 49%;
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    flex-direction: column;
    border-radius: 5px;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
    > p {
      width: 90%;
      font-size: 14px;
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      color: #333;
      /deep/.el-input__inner {
        // width: inherit;
        background: none;
        height: 32px;
        // line-height: 32px;
        color: #333;
        border: 1px solid rgba(0, 0, 0, 0.1);
        padding: 0 25px;
      }
      /deep/.el-input__icon {
        line-height: 32px;
      }
      /deep/.el-upload-dragger {
        width: 100%;
        height: 100px;
      }
      /deep/.el-upload-dragger .el-icon-upload {
        font-size: 60px;
        color: #c0c4cc;
        margin: 0;
        line-height: 1;
        width: 100%;
      }
      /deep/.el-upload {
        width: 100%;
      }
      .userselect {
        // max-width: 250px;
        flex: 1;
      }

      > span {
        display: block;
        width: 100px;
        text-align: right;
        padding-right: 15px;
        &:last-child {
          text-align: left;
          color: #888;
        }
      }
      > input {
        width: inherit;
        flex: 1;
        height: 32px;
        border-radius: 3px;
        border: 1px solid rgba(0, 0, 0, 0.1);
        padding-left: 10px;
        color: #333;
      }
      > strong {
        display: inline-block;
        padding-right: 50px;
        font-weight: 100;
        font-size: 14px;
        &:last-child {
          cursor: pointer;
          color: #13ce66;
          font-weight: 600;
        }
      }
      > div {
        width: inherit;
        flex: 1;
      }
    }
  }
}
.zd3-btm {
  background: rgba(255, 255, 255, 1);
  border-radius: 8px;
  // border: 1px solid rgba(0, 0, 0, 0.1);
  margin-top: 20px;
  overflow: hidden;
  &-title {
    display: flex;
    align-items: center;
    height: 70px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    background: #ffffff;
    > p {
      text-align: center;
      font-size: 16px;
      color: #333;
    }
  }
  .el-pagination {
    white-space: nowrap;
    padding: 15px 5px;
    color: #303133;
    font-weight: bold;
  }
  .addDate {
    margin: 20px 32px 10px 32px;
    height: 32px;
    border-radius: 3px;
    text-align: center;
    line-height: 32px;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    border: 1px dashed rgba(0, 0, 0, 0.25);
  }
  .el-button--text {
    margin: 0 15px;
  }
}
</style>
